<template>
	<view class="cantainer">
		<view class="input-box" v-for="(item,index) in data">
			<u-input  clearable border="bottom" class="u-input"  v-model="item.value">
					<template slot="prefix">
						<view class="text-box">
							<text class="text" v-if="item.must">*</text>{{item.title}}:
						</view>
					</template>
			</u-input>
		</view>
		<button v-text="'确定'" class="btn" @click="upInsert()"></button>
	</view>
</template>

<script>
	export default {
		name:"manager",
		data() {
			return {
				data:[
					{title:"P28综防科学性",value:"",abs:"p28",must:true},
					{title:"P29有害生物预警消警率",value:"",abs:"p29",must:true},
					{title:"R11自查问题上报率",value:"",abs:"r11",must:true},
					{title:"R12自查问题处置率",value:"",abs:"r12",must:true},
					{title:"R21应急预案科学性",value:"",abs:"r21",must:true},
					{title:"R24突发有害生物灾害处置情况",value:"",abs:"r24",must:true},
					{title:"P11上年度有害生物发生状态",value:"",abs:"p11",must:true},
					{title:"P12温度适宜性",value:"",abs:"p12",must:true},
					{title:"P13绿地健康水平",value:"",abs:"p13",must:true},
					{title:"P14有害生物危害性",value:"",abs:"p14",must:true},
					{title:"P23有害生物信息上报率",value:"",abs:"p23",must:true},
					{title:"P24有害生物监测上报及时性",value:"",abs:"p24",must:true},
					{title:"P25有害生物监测准确性",value:"",abs:"p25",must:true},
					{title:"P26植保培训参与率",value:"",abs:"p26",must:true},
					{title:"P27中度以上病虫草害发生情况",value:"",abs:"p27",must:true},
				],
				index:'',
			}
		},
		onLoad(options) {
			this.index = options.id
		},
		methods: {
			upInsert(){
				if(!this.verify()){
					this.$utils.errorMsg("请填写完整全部信息！")
					return;
				}
				let pages = getCurrentPages(); 
				let prevPage = pages[ pages.length - 2 ];  //上一页页面实例
				let manager = new Object;
				this.data.forEach(item=>{
					manager[item.abs] = item.value
				})
				prevPage.$vm.GreenLand[this.index].manager = manager;
				this.$utils.navigateBack(1)
			},
			verify(){
				let isVerify = true;
				try{
					this.data.forEach(item=>{
						if(item.must&&item.value==""){
							isVerify = false
							throw new Error("有选项未填写");
						}
						
					})
				}catch(e){
					
				}
				return isVerify;
			}
		}
	}
</script>

<style scoped>
	.cantainer{
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		justify-content: center;
		padding: 20rpx;
	}
	.text{
		color: red;
		
	}
	.input-box{
		background-color: #d9ffdc;
		border-radius: 20rpx;
		margin: 20rpx 0;
		width: 100%;
	}
	.u-input{
		width: 100%;
	}
	.btn{
		color: #ffffff;
		width: 100%;
		background-color: #348669;
		border-radius: 20rpx;
		margin-top: 2%;
	}
</style>

